package proxy.candymachinermi;

import java.rmi.Naming;

/**
 * @description: 用Java RMI 实现远程监控糖果机状态的需求 客户端
　* @author 周杨
　* @date 2019/6/13  12:43
**/
public class Main {
    //直接往监控里增加远程糖果机的对象
    public static void main(String[] args) {
        Monitor monitor = new Monitor();
        try {
            //直接可以拿到这个对象 序列化的过程不必关心
            CandyMachineRemote candyMachineRemote = (CandyMachineRemote) Naming.lookup("rmi://127.0.0.1:6602/test1");
            monitor.addMachine(candyMachineRemote);
            candyMachineRemote = (CandyMachineRemote)Naming.lookup("rmi://127.0.0.1:6602/test2");
            monitor.addMachine(candyMachineRemote);
        }catch (Exception e){
            e.printStackTrace();
        }
        monitor.report();
    }
}
